<!-- @author mrduongnv@gmail.com -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<%@include file="/WEB-INF/taglibs/common/taglibs.jsp"%>
<head>

<title><spring:message code="admin.settings.title" /></title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" href="<c:url value="/css/styles.css"/>" />
<link rel="stylesheet" href="<c:url value="/javascripts/jscalendar/theme/calendar-system.css"/>" />
<script src="<c:url value="/javascripts/jscalendar/calendar-cfg.js"/>" type="text/javascript"></script>
<script src="<c:url value="/javascripts/calendar.js"/>" type="text/javascript"></script>
<script src="<c:url value="/javascripts/jscalendar/lang/calendar-en.js"/>" type="text/javascript"></script>
<script src="<c:url value="/javascripts/jscalendar/calendar-setup.js"/>" type="text/javascript"></script>
<script src="<c:url value="/javascripts/common.js"/>" type="text/javascript"></script>

<script language="javascript" type="text/javascript">
	function validateForm() {
		with (document.getElementById("newFee")) {
			if (value == null || !isNumeric(value) || value <= 0) {
				alert("Please enter valid default fee value.");
				return false;
			} else {
				return true;
			}
		}
	}
    function areYouSure(fee, date, url) {
        var r = confirm("Are you sure you want to delete Default fee of $" + fee +
              ", effective from " + date + "?");
        if(r) {
            window.location.replace(url);
        }
    }
    function confirmSubmit(text) {
        return confirm('Are you sure you want to ' + text + '?');
    }
</script>

</head>

<body><%@include file="../top_menu.jsp"%>

<table width=100%>
	<tr>
		<td><%@include file="/WEB-INF/jsp/include/messages.jsp"%>
		<br />
		</td>
	</tr>
</table>

<form:form id="main" commandName="settings" method="post">

<table width=70% class="formTable">

	<tr class="formHeader">
		<td colspan="5"><spring:message code="admin.settings.label.settings" /></td>
	</tr>
	<tr>
		<th width="50%"><spring:message code="admin.settings.label.name" /></th>
		<th><spring:message code="admin.settings.label.value" /></th>
	</tr>

	<tbody>
        <tr>
		    <td width="50%"><spring:message code="admin.settings.label.uitheme" /></td>
			<td><form:select path="uiTheme"  id="uiTheme" >
				    <form:options items="${uiThemes}"/>
			    </form:select>

            </td>
		</tr>
        <tr>
		    <td width="50%"><spring:message code="admin.create.user.checkprintingby" /></td>
			<td><table border="0" width="100%"><tr>
                    <td><form:radiobutton path="checkPrintBy" value="1"/><spring:message code="admin.create.user.checkprintingby.admin"/></td>
                    <td><form:radiobutton path="checkPrintBy" value="2"/><spring:message code="admin.create.user.checkprintingby.sp"/></td>
                    <td><form:radiobutton path="checkPrintBy" value="0"/><spring:message code="admin.create.user.orderapproval.notdefined"/></td>
                </tr></table>
            </td>
		</tr>
        <tr>
		    <td width="50%"><spring:message code="admin.create.user.orderapproval" /></td>
			<td><table border="0" width="100%"><tr>
                    <td><form:radiobutton path="orderApproval" value="1"/><spring:message code="admin.create.user.orderapproval.auto"/></td>
                    <td><form:radiobutton path="orderApproval" value="2"/><spring:message code="admin.create.user.orderapproval.manual"/></td>
                    <td><form:radiobutton path="orderApproval" value="0"/><spring:message code="admin.create.user.orderapproval.notdefined"/></td>
                </tr></table>
            </td>
		</tr>
        <tr>
            <td></td>
            <td><input type="submit" class='ui-button ui-state-default ui-corner-all' name="theme" value="<spring:message code="admin.settings.button.save" />" /></td>
        </tr>

        <tr>
            <td><spring:message code="admin.settings.label.effectivefees" /></td>
		    <td>
                <table class="formTable">
                    <tr class="formHeader">
                        <td><spring:message code="admin.settings.label.defaultfee" /></td>
                        <td><spring:message code="admin.settings.label.effectivefrom" /></td>
                        <td width="1%"><img src="<c:url value="/images/close_over.gif"/>" alt="Delete Default Fee"></td>
                    </tr>
                <c:forEach items="${settings.allFees}" var="fee" varStatus="i">
                    <tr>
                        <td><form:input path="allFees[${i.index}].fee" readonly="true" cssStyle="border: 0"/></td>
                        <td><form:hidden path="allFees[${i.index}].id" />
                        <form:input path="allFees[${i.index}].effectiveFrom" readonly="true" cssStyle="border: 0"/></td>
                        <td width="1%"><a href="#" onclick="areYouSure('${fee.fee / 100.0}', '${fee.effectiveFrom}', 'delete_fee.htm?id=${fee.id}')">
                            <img src="<c:url value="/images/close.gif"/>" alt="Delete this Fee"></a>
                        </td>
                    </tr>
                </c:forEach>
                </table>
            </td>
		</tr>
        <tr>
		    <td width="50%"><spring:message code="admin.settings.label.defaultfee" /></td>
            <td><form:input path="newFee" size="10"/> <spring:message code="admin.settings.label.effectivefrom" />
                <component:calendar bindPath="newEffectiveFrom"/>
            <input type="submit" class='ui-button ui-state-default ui-corner-all' name="add" value="<spring:message code="admin.settings.button.add" />" /></td>
        </tr>
        <tr><td width="50%">&nbsp;</td>
			<td><form:errors path="newFee" cssClass="errors"/></td>
		</tr>
        <tr>
		    <td width="50%"><spring:message code="admin.settings.label.spactive" /></td>
            <td><table border="0" width="100%"><tr>
                    <td><input onClick="return confirmSubmit('<spring:message code="admin.settings.label.spactive" /> ' + '<spring:message code="admin.settings.button.active" />')"
                            type="submit" class='ui-button ui-state-default ui-corner-all' name="spactive" value="<spring:message code="admin.settings.button.active" />" /></td>
                    <td><input onClick="return confirmSubmit('<spring:message code="admin.settings.label.spactive" /> ' + '<spring:message code="admin.settings.button.inactive" />')"
                               type="submit" class='ui-button ui-state-default ui-corner-all' name="spinactive" value="<spring:message code="admin.settings.button.inactive" />" /></td>
                </tr></table>
            </td>
        </tr>
        <tr>
		    <td width="50%"><spring:message code="admin.settings.label.payeeactive" /></td>
            <td><table border="0" width="100%"><tr>
                    <td><input onClick="return confirmSubmit('<spring:message code="admin.settings.label.payeeactive" /> ' + '<spring:message code="admin.settings.button.active" />')"
                               type="submit" class='ui-button ui-state-default ui-corner-all' name="payeeactive" value="<spring:message code="admin.settings.button.active" />" /></td>
                    <td><input onClick="return confirmSubmit('<spring:message code="admin.settings.label.payeeactive" /> ' + '<spring:message code="admin.settings.button.inactive" />')"
                               type="submit" class='ui-button ui-state-default ui-corner-all' name="payeeinactive" value="<spring:message code="admin.settings.button.inactive" />" /></td>
                </tr>
            <c:if test="${!empty settings.message}">
                <tr><td colspan="2" class="errors"><spring:message code="admin.settings.message.${settings.message}" /></td></tr>
            </c:if>
            </table>
            </td>
        </tr>


	</tbody>
</table>


</form:form>

<%@include file="/WEB-INF/jsp/include/footer.jsp"%>

</body>

</html>